package ${file.packageName};

import com.ezbuy.common.functions.Consumer;
import com.ezbuy.common.functions.Mapper;
import com.ezbuy.common.request.RequestObserver;
import com.ezbuy.common.request.RxExecuter;
import com.ezbuy.common.request.RxRequestObserver;

import ${file.grpcPackageName}.${file.name}Grpc;
import ${file.grpcPackageName}.${file.name}OuterClass;
import io.reactivex.disposables.Disposable;

public class ${name}ServiceImpl implements ${name}Service {

    <#list methods as method>
    @Override
    public RequestObserver ${method.name}(${method.inputType} req, Consumer<${method.outputType}> consumer) {
        Disposable disposable = RxExecuter.execute(req, consumer, new Mapper<${method.inputType}, ${method.outputType}>() {
            @Override
            public ${method.outputType} map(${method.inputType} req) {
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                ${file.name}OuterClass.${method.outputType} resp = ${name}Grpc.newBlockingStub(null).${method.name}(new ${method.inputType}Mapper().toGrpc(req));
                return new ${method.outputType}Mapper().fromGrpc(resp);
            }
        });
        return new RxRequestObserver(disposable);
    }
    
    </#list>
}